﻿#region Includes
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Text;
#endregion

namespace pxt
{
    public class StatusBar
    {
    #region Members
        private Texture2D m_BaseTexture;
        private Texture2D m_OverlayTexture;
        private float m_fPercentage;
        private Vector2 mScale;
        private Color mBaseColor;
        private Color mOverColor;
    #endregion
    #region Functions
        public StatusBar(Vector2 scale, Color baseColor, Color overColor)
        {
            mScale = scale;
            mOverColor = overColor;
            mBaseColor = baseColor;
            m_BaseTexture = GameGlobals.Content.Load<Texture2D>("sprites\\unit_frames\\health_base");
            m_OverlayTexture = GameGlobals.Content.Load<Texture2D>("sprites\\unit_frames\\health_overlay");
            m_fPercentage = 1.0f;
        }

        /// <summary>
        /// Updates the Health Bar
        /// </summary>
        /// <param name="gt"></param>
        /// <param name="hpPercent"> Send this as a float from 0.0 to 1.0</param>
        public void Update(GameTime gt, float hpPercent)
        {
            m_fPercentage = hpPercent;
        }

        public void Draw(Vector2 pos)
        {
            Rectangle rect = new Rectangle(0, 0, (int)(m_OverlayTexture.Width * m_fPercentage), m_OverlayTexture.Height);
            GameSystems.Graphics.SpriteBatch.Draw(m_BaseTexture, pos, null, mBaseColor, 0.0f, new Vector2(0.0f, 0.0f), mScale, SpriteEffects.None, 0.0f);
            GameSystems.Graphics.SpriteBatch.Draw(m_OverlayTexture, pos, rect, mOverColor, 0.0f, new Vector2(0.0f, 0.0f), mScale, SpriteEffects.None, 0.0f);
        }
    #endregion
    #region Properties
    #endregion
    }
}
